import random
from datetime import datetime
from typing import Dict, Any
from config.settings import DEFAULT_PRICE, PRICE_FLUCTUATION

class MockDataGenerator:
    def __init__(self):
        self.base_price = DEFAULT_PRICE
        
    def generate_ticker_data(self, inst_id: str, inst_type: str) -> Dict[str, Any]:
        price = self.base_price + random.uniform(-PRICE_FLUCTUATION, PRICE_FLUCTUATION)
        return {
            "action": "update",
            "arg": {
                "instType": inst_type,
                "channel": "ticker",
                "instId": inst_id
            },
            "data": [{
                "instId": inst_id,
                "last": f"{price:.2f}",
                "lastSz": "0.01",
                "askPx": f"{price + 0.5:.2f}",
                "askSz": "1.0",
                "bidPx": f"{price - 0.5:.2f}",
                "bidSz": "1.0",
                "volume24h": "1000.0",
                "ts": str(int(datetime.now().timestamp() * 1000))
            }]
        }
        
    def generate_order_data(self, inst_id: str, inst_type: str) -> Dict[str, Any]:
        status = random.choice(["live", "filled", "cancelled"])
        order_id = f"mock_order_{int(datetime.now().timestamp() * 1000)}"
        return {
            "action": "update",
            "arg": {
                "instType": inst_type,
                "channel": "orders",
                "instId": inst_id
            },
            "data": [{
                "orderId": order_id,
                "clientOid": f"mock_client_{order_id}",
                "size": "0.01",
                "price": f"{self.base_price:.2f}",
                "status": status,
                "ts": str(int(datetime.now().timestamp() * 1000))
            }]
        } 